using System;
using NUnit.Framework;
using RMH.DataAccess;
using RMH.Entities;
using RMH.UnitTests;
using RMH.Web;

namespace RMH.IntegrationTests.Repository
{
    [TestFixture]
    public class NoteRepository_when_saving : base_test
    {
        string body = "what a dude";
        DateTime noteDate = new DateTime(2009,1,20);

        private Note note;
        
        public override void because()
        {
            var noteRepository = Container.Resolve<NoteRepository>();
            note = new Note {Body = body, Date = noteDate, StaffId = "foo"};
            noteRepository.Save(note);
            noteRepository.Flush();
            noteRepository.Clear();
            note = noteRepository.GetByID(note.Id);            
        }

        [Test]
        public void body_is_persisted()
        {
            note.Body.ShouldEqual(body);
        }

        [Test]
        public void date_is_persisted()
        {
            note.Date.ShouldEqual(noteDate);
        }

        [Test]
        public void staff_member_is_persisted()
        {
            note.StaffId.ShouldEqual("foo");
        }
    }
}